package WaiBao;

import java.util.Arrays;

public class LiuShuXing {
    public static void main(String[] args) {
        String[] name = {"钟孟岩(班长)", "乐伴锋(副班长)", "小李(学习委员)", "金玲(宣传委员)", "范先荣", "和唐翠", "梁悄悄", "王培树", "倪萍", "张丽", "朱红", "周扬",
                "鲁钟意", "王混批", "梅先志", "戚相遇", "王赞群", "施放好", "严祥", "文儒雅", "张柏芝", "张艺谋", "张文远", "李现", "肖战", "王一博", "王战", "李志阳",
                "林浩纯", "刘淑馨(学生)"};//考生本人:刘淑馨(学生)
        int[] age = {20, 21, 21, 19,20, 21, 21, 21, 19, 18,21, 22, 18, 20,22, 19, 18, 19, 18, 20, 19, 19, 20, 20, 20, 18, 20,20,19, 20};

        double[] luocha1 = {78, 80, 85, 90, 88, 66, 70, 59, 60, 70, 90, 87, 85, 79, 65, 68, 69, 99, 96, 88, 92, 91, 95, 85, 75, 74, 74, 86, 80, 95};
        double[] luocha2 = {79, 80, 78, 69, 68, 97, 88, 69, 90, 60, 90, 67, 86, 75, 65, 65, 86, 79, 66, 78, 82, 71, 85, 85, 75, 89, 74, 70, 85, 96};
        double[] luocha3 = {88, 89, 89, 95, 99, 99, 69, 89, 80, 60, 93, 87, 85, 85, 65, 98, 89, 79, 96, 63, 92, 81, 95, 85, 76, 88, 73, 79, 77, 94};

        double guang1;//代表每个学生的总分
        double guang2;//代表每个学生的平均分
//        for (int i = 0; i < 30; i++) {
//            guang1 = luocha1[i] + luocha2[i] +luocha3[i];
//            guang2 = (guang1 * 1.0) / 3;
//            System.out.println(name[i] + "的总分为:" + guang1);
//            System.out.println(name[i] + "的平均分为:" +guang2);
//        }


        double laizi1 = 0, laizi2 = 0;
        double[] buwei = new double[30];
//        for (int i = 0; i < 30; i++) {
//            laizi1 = luocha1[i] + luocha2[i] + luocha3[i];
//            laizi2= (laizi1 * 1.0) / 3;
//            buwei[i] = laizi2;
//        }
//
//        for (int i = 0; i <buwei.length - 1; i++) {
//            for (int j = 0; j <buwei.length - i - 1; j++) {
//                if (buwei[j] < buwei[j + 1]) {
//                    double temp = buwei[j];
//                    buwei[j] = buwei[j + 1];
//                    buwei[j + 1] = temp;
//                }
//            }
//        }
//        System.out.println("前十名同学的成绩为:");
//        for (int i = 0; i < 10; i++) {
//            System.out.println(buwei[i]);
//        }


        double dao1 = 0, dao2 = 0, dao3 = 0;//计算每门课的平均分
        double jiang1 = 0, jiang2 = 0, jiang3 = 0;//计算每门课标准差
        double tang1 = 0, tang2 = 0, tang3 = 0;//计算每门课中位数
        double sum2 = 0;
        for (int i = 0; i < luocha1.length; i++) {
            sum2+=luocha1[i];
        }
        dao1 = (sum2*1.0)/30;
        System.out.println("分析化学的班级平均分为:"+dao1);
        double Sum = 0;
        for (int i = 0; i <luocha2.length; i++) {
            Sum+=luocha2[i];
        }
        dao2 = (Sum*1.0)/30;
        System.out.println("线性代数的班级平均分为:"+dao2);
        double sum = 0;
        for (int i = 0; i <luocha3.length; i++) {
            sum+=luocha3[i];
        }
        dao3 = (sum*1.0)/30;
        System.out.println("有机化学的班级平均分为:"+dao3);


        double c1 = 0,c2 = 0,c3 = 0;
        for (int i = 0; i <luocha1.length; i++) {
            c1+= (luocha1[i] -dao1)*(luocha1[i] - dao1);
        }
        jiang1 = Math.sqrt(c1*1.0/30);
        System.out.println("分析化学的班级标准差为:"+jiang1);

        for (int i = 0; i <luocha2.length; i++) {
            c2+= (luocha2[i] - dao2)*(luocha2[i] - dao2);
        }
        jiang2 = Math.sqrt(c2*1.0/30);
        System.out.println("线性代数的班级标准差为:"+jiang2);

        for (int i = 0; i < luocha3.length; i++) {
            c3+= (luocha3[i] - dao3)*(luocha3[i] -dao3);
        }
        jiang3 = Math.sqrt(c3*1.0/30);
        System.out.println("有机化学的班级标准差为:"+jiang3);
//
//        Arrays.sort(luocha1);
//        Arrays.sort(luocha2);
//        Arrays.sort(luocha3);
//        tang1 =(luocha1[15]+luocha1[16])*1.0/2;
//        tang2 =(luocha2[15]+luocha2[16])*1.0/2;
//        tang3 =(luocha3[15]+luocha3[16])*1.0/2;
//        System.out.println("分析化学的中位数为:"+tang1);
//        System.out.println("线性代数的中位数为:"+tang2);
//        System.out.println("有机化学学的中位数为:"+tang3);






    }
}
